GtkWindow: Make it an application/x-rootwindow-drop destination
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 9 Mar 2016 16:37:27 +0000 (17:37 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 14 Mar 2016 15:16:32 +0000 (16:16 +0100)
This makes toplevels pseudo-transparent wrt this mimetype, so if
the drag source offers this mimetype and not another that was
managed by the destination-side widget hierarchy, the window will
be an acceptable target for this mimetype, allowing it to trigger
whatever is meant to in the source side.

https://bugzilla.gnome.org/show_bug.cgi?id=763387

gtk/gtkwindow.c

index a2be09da834292a6ca714d8c4065820f68818617..3e8d321edb2a77cb40b70e10b40c87a02f878bb6 100644 (file)
@@ -272,6 +272,10 @@ struct _GtkWindowPrivate
   GtkCssNode *decoration_node;
 };
 
+static const GtkTargetEntry dnd_dest_targets [] = {
+  { "application/x-rootwindow-drop", 0, 0 },
+};
+
 enum {
   SET_FOCUS,
   FRAME_EVENT,
@@ -1693,6 +1697,11 @@ gtk_window_init (GtkWindow *window)
   gtk_css_node_add_class (widget_node, g_quark_from_static_string (GTK_STYLE_CLASS_BACKGROUND));
 
   priv->scale = gtk_widget_get_scale_factor (widget);
+
+  gtk_drag_dest_set (GTK_WIDGET (window),
+                     GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+                     dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets),
+                     GDK_ACTION_MOVE);
 }
 
 static void